<?php

/**
 *  modle of authClass
 *
 * @access public
 * @return void
 */
class MAuth extends CI_Model
{
    //默认配置
    protected $_auth = array(
        'AUTH_ON' => true,                      // 认证开关
        'AUTH_TYPE' => 1,                         // 认证方式，1为实时认证；2为登录认证。
        'AUTH_GROUP' => 'auth_group',        // 用户组数据表名
        'AUTH_GROUP_ACCESS' => 'auth_group_access', // 用户-用户组关系表
        'AUTH_RULE' => 'auth_rule',         // 权限规则表
        'AUTH_USER' => 'member'             // 用户信息表
    );
    private $plat;

    function MAuth()
    {
        parent::__construct();
        //$this->plat = $this->authboss->getplat();
    }

    function addCard($data = array())
    {

        $data['plat'] = $this->plat;
        $this->db->insert('tblnewcard', $data);
        return $this->db->insert_id();
    }

    //测试的
    function test()
    { //Array ( [0] => Array ( [uid] => 2 [group_id] => 3 [title] => 运营专员 [rules] => 1,2,3,4,23,24 ) )
        return 222;

    }


    //根据用户id获取用户组,返回值为数组
    function getGroups($uid)
    {
        //方法一
        /*
        $this->db->select('*');
        $this->db->from("auth_group_access");
        $this->db->where('uid', 2);
        $this->db->join("auth_group", "auth_group.id = auth_group_access.group_id");
        $query = $this->db->get();
        return $query->result_array();
        */

        //方法二
        $sql = "select * from d_group where id = 3";
        $query = $this->db->query($sql);
        //$user_groups =  $query->result_array();
        //$groups[$uid]=$user_groups?:array();
        //return $groups[$uid];
        return $query->result_array();
    }

    function getAuthList($map, $ids)
    {
        $this->db->select('*');
        $this->db->where($map);
        $this->db->where_in('id', $ids);
        $query = $this->db->get('d_menu');
        return $query->result_array();
    }




}

?>